package com.zaizai.zaizai_good.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zaizai.zaizai_good.domain.R;
import com.zaizai.zaizai_good.utils.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zaizai.zaizai_good.domain.pojo.Storage;
import com.zaizai.zaizai_good.service.IStorageService;
/**
 * 仓库Controller
 * 
 * @author lql
 * @date 2024-10-04
 */
@RestController
@RequestMapping("/storage")
public class StorageController extends BaseController
{
    @Autowired
    private IStorageService storageService;

    /**
     * 查询仓库列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Storage storage)
    {
        startPage();
        List<Storage> list = storageService.selectStorageList(storage);
        return getDataTable(list);
    }


    /**
     * 获取仓库详细信息
     */
    @GetMapping(value = "/{id}")
    public R<Storage> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(storageService.selectStorageById(id));
    }

    /**
     * 新增仓库
     */
    @PostMapping
    public R<Integer> add(@RequestBody Storage storage)
    {
        return R.ok(storageService.insertStorage(storage));
    }

    /**
     * 修改仓库
     */
    @PutMapping
    public R<Integer> edit(@RequestBody Storage storage)
    {
        return R.ok(storageService.updateStorage(storage));
    }

    /**
     * 删除仓库
     */
	@DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable Long[] ids)
    {
        return R.ok(storageService.deleteStorageByIds(ids));
    }
}
